package com.shenmazong.mq.controller;

import com.shenmazong.utils.ResultResponse;
import com.shenmazong.vo.MessageVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 军哥
 * @version 1.0
 * @description: TODO
 * @date 2022/7/5 10:45
 */

@RestController
@Slf4j
@RequestMapping(value = "/message")
public class MessageController {

    @Autowired
    RabbitTemplate rabbitTemplate;

    @PostMapping(value = "/sendMessage")
    public ResultResponse sendMessage(@RequestBody MessageVo messageVo) {

        rabbitTemplate.convertAndSend("simpleQueue", messageVo);
        System.out.println(messageVo);

        return ResultResponse.SUCCESS();
    }

}
